package top.fengyulou.xiaofeng.common;

import org.springframework.util.DigestUtils;

import java.util.HashMap;
import java.util.Map;

public class MyUtils {

    /**
     * 选项数组
     */
    public static String[] OPTIONS = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};

    /**
     * 选项索引
     */
    public static Map<String, Integer> OPTION_INDEX = new HashMap<>();

    /**
     * 题型
     */
    public static Map<String,String> qstTypeMap=new HashMap<>();

    static {
        OPTION_INDEX.put("A", 0);
        OPTION_INDEX.put("B", 1);
        OPTION_INDEX.put("C", 2);
        OPTION_INDEX.put("D", 3);
        OPTION_INDEX.put("E", 4);
        OPTION_INDEX.put("F", 5);
        OPTION_INDEX.put("G", 6);
        OPTION_INDEX.put("H", 7);
        OPTION_INDEX.put("I", 8);
        OPTION_INDEX.put("J", 9);
        OPTION_INDEX.put("K", 10);
        OPTION_INDEX.put("L", 11);
        OPTION_INDEX.put("M", 12);
        OPTION_INDEX.put("N", 13);
        OPTION_INDEX.put("O", 14);
        OPTION_INDEX.put("P", 15);
        OPTION_INDEX.put("Q", 16);
        OPTION_INDEX.put("R", 17);
        OPTION_INDEX.put("S", 18);
        OPTION_INDEX.put("T", 19);
        OPTION_INDEX.put("U", 20);
        OPTION_INDEX.put("V", 21);
        OPTION_INDEX.put("W", 22);
        OPTION_INDEX.put("X", 23);
        OPTION_INDEX.put("Y", 24);
        OPTION_INDEX.put("Z", 25);

        //题型索引
        qstTypeMap.put("A","单选题");
        qstTypeMap.put("B","多选题");
        qstTypeMap.put("C","判选题");
        qstTypeMap.put("D","主观题");
    }

    /**
     * md5加密
     *
     * @param str
     * @return
     */
    public static String getMd5(String str) {
        return DigestUtils.md5DigestAsHex(str.getBytes());
    }
}
